#include <cctype>
#include <cmath>
#include <cstdio>

int const N = 32000;

template <typename T>
inline T &read(T &x) {
  x = 0;
  bool f = false;
  short ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + (ch ^ '0'), ch = getchar();
  if (f) x = -x;
  return x;
}

int n, t, cnt;
int sqr[N], fact[20];

int calc(int n) {
  int ret = 0;
  for (int i = 1, j = sqrt(n); i <= j;) {
    int x = sqr[i] + sqr[j];
    if (x == n) ret++;
    if (x >= n) j--;
    if (x <= n) ++i;
  }
  return ret;
}

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("sqr.in", "r", stdin);
  freopen("sqr.out", "w", stdout);
#endif
#endif

  for (int i = 0; i < N; ++i) sqr[i] = i * i;
  read(t);
  while (t--) {
    read(n);
    if (n & 1) {
      puts("0");
      continue;
    }
    n /= 2;
    int cnt = 0, ans = 0, _n = n;
    for (int i = 2; i * i <= _n; ++i) {
      if (_n % i == 0) {
        fact[++cnt] = i;
        while (_n % i == 0) _n /= i;
      }
    }
    if (_n != 1) fact[++cnt] = _n;
    for (int i = 0; i < 1 << cnt; ++i) {
      int g = 1;
      for (int j = 1; j <= cnt; j++) {
        if (i & (1 << (j - 1))) g *= fact[j];
      }
      ans += calc(n / g);
    }
    printf("%d\n", ans);
  }
  return 0;
}